"""
Copyright (c) 2023 - present SKbioinfo
"""
from flask_restful import Api
from apps.NGS_API.bioana.interface_bioana import interfaceBioana,interfaceBioanaID,interfaceBioanaList,interfacegenerateBioanaid
#from apps.API.sample.interface_sample import interfaceSample,interfaceSampleID,interfaceAmounteditID,interfacegenerateSamID
from apps.NGS_API.sample.interface_sample_stock import interfaceOutstockID,interfaceOutamountID,interfaceSampleStock,interfaceSamtableStock
from apps.NGS_API.user.interface_user import interfaceUser,interfaceUserID
from apps.NGS_API.role.interfece_role import interfaceRole
from apps.NGS_API.project.interface_project import interfaceProject,interfaceProjectID
from apps.NGS_API.extraction.interface_extration import interfaceExtraction,interfaceExtractionID
from apps.NGS_API.ngsLib.interface_ngsLib import interfacengsLib,interfacengsLibID
from apps.NGS_API.stock.interface_stock import interfaceStock,interfaceStockID
from apps.NGS_API.fileup.interface_fileup import interfaceUploadAdd,interfaceUploadDel,interfaceUploadOut,interfaceUploadUpd
from apps.NGS_API.charts.interface_piechart import interfaceProjectPie,interfaceExtractionPie
from apps.NGS_API.charts.interface_bioana_chart import interfaceMontlyAnaLine,interfaceRecentAnaBar,interfaceAnaPie
from apps.NGS_API.charts.interface_sample_chart import interfaceMonthlySampleLine,interfaceSampleBar
from apps.NGS_API.time_picker.interface_timepicker import interfaceProjectTimePicker,interfaceSampleTimePicker
from apps.NGS_API.tableup.interface_tableup import interfaceTableupload,interfacegenerateExtID,interfacegenerateLibID
from apps.NGS_API.tableup.interface_tableup import interfaceTableExtractionID,interfaceTablengsLibID,interfacegenerateStcID
from apps.NGS_API.tableup.interface_tableup import interfaceTableExtractionQC,interfaceTablengsLibQC,interfaceExtquery
from apps.NGS_API.tableup.interface_tablesearch import interfaceTablesearch,interfaceTableSamplesearch
from apps.NGS_API.record.interface_operate_his import interfaceUseroperateHis,interfaceOperSearch
from apps.NGS_API.API_config import API_SETTING

def register_ngs_api(apps):
    ### INITIAL RESTFUL API ###
    api=Api(apps) 
    ### SETTING API URL ###
    APIs=API_SETTING.API_config
    ### REGISTER USER API ###
    api.add_resource(interfaceUser, APIs["USER_API"], endpoint = "user")
    api.add_resource(interfaceUserID, APIs["USER_API"] + "/<string:id>")
    ### REGISTER ROLE INFOS ###
    api.add_resource(interfaceRole, APIs["USER_API"] + "/role")
    ### REGISTER PROJECT API ###
    api.add_resource(interfaceProject,APIs["PROJECT_API"], endpoint = "project")
    api.add_resource(interfaceProjectID,APIs["PROJECT_API"] + "/<string:id>")
    ### REGISTER SAMPLE API ###
    # api.add_resource(interfaceSample, APIs["SAMPLE_API"], endpoint = "sample")
    # api.add_resource(interfaceSampleID, APIs["SAMPLE_API"] + "/<string:id>")
    api.add_resource(interfaceOutstockID, APIs["SAMPLE_API"] + "/outstock/<string:id>")
    # api.add_resource(interfaceAmounteditID, APIs["SAMPLE_API"] + "/edit/<string:id>")
    api.add_resource(interfaceOutamountID, APIs["SAMPLE_API"] + "/out_amount/<string:id>")
    api.add_resource(interfaceSampleStock, APIs["SAMPLE_API"] + "/instock")
    api.add_resource(interfaceSamtableStock, APIs["SAMPLE_API"] + "/table/instock")
    # api.add_resource(interfacegenerateSamID, APIs["SAMPLE_API"] + "/sample_id")
    ### REGISTER BIOANA API ###
    api.add_resource(interfaceBioana,APIs["BIOANA_API"], endpoint = 'bioana')
    api.add_resource(interfaceBioanaList,APIs["BIOANA_API"] + "/list")
    api.add_resource(interfaceBioanaID,APIs["BIOANA_API"] + "/<string:id>")
    api.add_resource(interfacegenerateBioanaid,APIs["BIOANA_API"] + "/bioana_id")
    ### REGISTER EXTRACTION API ###
    api.add_resource(interfaceExtraction,APIs["EXTRACTION_API"], endpoint = "extraction")
    api.add_resource(interfaceExtractionID,APIs["EXTRACTION_API"] + "/<string:id>")
    ### REGISTER NGSLIB API ###
    api.add_resource(interfacengsLib, APIs["NGSLIB_API"], endpoint = "ngslib")
    api.add_resource(interfacengsLibID, APIs["NGSLIB_API"] + "/<string:id>")
    ### REGISTER STOCK API ###
    api.add_resource(interfaceStock, APIs["STOCK_API"], endpoint = "stock")
    api.add_resource(interfaceStockID, APIs["STOCK_API"] + "/<string:id>")
    ### REGISTER UPLOAD API ###
    api.add_resource(interfaceUploadAdd, APIs["FILEUPLOAD_API"] + "/add/<string:name>")
    api.add_resource(interfaceUploadDel, APIs["FILEUPLOAD_API"] + "/del/<string:name>")
    api.add_resource(interfaceUploadOut, APIs["FILEUPLOAD_API"] + "/out/<string:name>")
    api.add_resource(interfaceUploadUpd, APIs["FILEUPLOAD_API"] + "/upd/<string:name>")
    ### REGISTER PIE PLOT API ###
    api.add_resource(interfaceProjectPie, APIs["CHARTS_API"] + "/pieCharts/project")
    api.add_resource(interfaceExtractionPie, APIs["CHARTS_API"] + "/pieCharts/extraction")
    api.add_resource(interfaceAnaPie, APIs["CHARTS_API"] + "/pieCharts/bioana")
    ### REGISTER BAR PLOT API ###
    api.add_resource(interfaceRecentAnaBar, APIs["CHARTS_API"] + "/barCharts/recent_bioana")
    api.add_resource(interfaceSampleBar, APIs["CHARTS_API"] + "/barCharts/sample")
    ### REGISTER LINE PLOT API ###
    api.add_resource(interfaceMontlyAnaLine, APIs["CHARTS_API"] + "/lineCharts/recent_bioana")
    api.add_resource(interfaceMonthlySampleLine, APIs["CHARTS_API"] + "/lineCharts/sample")
    ### REGISTER TIME PICKER ###
    api.add_resource(interfaceProjectTimePicker, APIs["TIME_PICKER_API"] + "/projects")
    api.add_resource(interfaceSampleTimePicker, APIs["TIME_PICKER_API"] + "/samples")
    ### REGISTER TABLE UPLOAD API (extraction & library upload) ###
    api.add_resource(interfaceTableupload, APIs["TABLE_API"] + "/table_upload")
    api.add_resource(interfacegenerateExtID, APIs["TABLE_API"] + "/extraction/ext_id")
    api.add_resource(interfacegenerateLibID, APIs["TABLE_API"] + "/ngsLib/ngs_id")
    api.add_resource(interfacegenerateStcID, APIs["TABLE_API"] + "/stock/stock_id")
    api.add_resource(interfaceTableExtractionID, APIs["TABLE_API"] + "/extraction/add/<string:id>")
    api.add_resource(interfaceTablengsLibID, APIs["TABLE_API"] + "/ngsLib/add/<string:id>")
    api.add_resource(interfaceTablesearch, APIs["TABLE_API"] + "/search")
    api.add_resource(interfaceTableSamplesearch, APIs["TABLE_API"] + "/sample/search")
    api.add_resource(interfaceTablengsLibQC, APIs["TABLE_API"] + "/ngsLib/qc")
    api.add_resource(interfaceTableExtractionQC, APIs["TABLE_API"] + "/extraction/qc")
    api.add_resource(interfaceExtquery, APIs["TABLE_API"] + "/extraction/query_amount")
    ### REGISTER RECORD API: /api/record ###
    api.add_resource(interfaceUseroperateHis, APIs["RECORD_API"] + "/user_operate")
    api.add_resource(interfaceOperSearch,APIs["RECORD_API"] + "/user_op_search")
    
    